<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>Python | C·辰</title><meta name="author" content="辰"><meta name="copyright" content="辰"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="Python">
<meta property="og:type" content="article">
<meta property="og:title" content="Python">
<meta property="og:url" content="http://example.com/2021/05/02/Python/index.html">
<meta property="og:site_name" content="C·辰">
<meta property="og:description" content="Python">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://chen-1317386995.cos.ap-guangzhou.myqcloud.com/Blog/images/PYTHON.png">
<meta property="article:published_time" content="2021-05-02T14:22:22.000Z">
<meta property="article:modified_time" content="2023-07-27T10:16:06.808Z">
<meta property="article:author" content="辰">
<meta property="article:tag" content="Python">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://chen-1317386995.cos.ap-guangzhou.myqcloud.com/Blog/images/PYTHON.png"><link rel="shortcut icon" href="https://chen-1317386995.cos.ap-guangzhou.myqcloud.com/Blog/images/Bell.ico"><link rel="canonical" href="http://example.com/2021/05/02/Python/index.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.xml","languages":{"hits_empty":"找不到您查询的内容：${query}","hits_stats":"共找到 ${hits} 篇文章"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  dateSuffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: true,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: false,
  }
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'Python',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2023-07-27 18:16:06'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
    win.getCSS = (url,id = false) => new Promise((resolve, reject) => {
      const link = document.createElement('link')
      link.rel = 'stylesheet'
      link.href = url
      if (id) link.id = id
      link.onerror = reject
      link.onload = link.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        link.onload = link.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(link)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><meta name="generator" content="Hexo 6.3.0"></head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src= "" data-lazy-src="/img/loading.gif" data-original="https://chen-1317386995.cos.ap-guangzhou.myqcloud.com/Blog%2Fimages%2Favatar.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">32</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">28</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">10</div></a></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fa fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fa fa-graduation-cap"></i><span> 博文</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/categories/"><i class="fa-fw fa fa-folder-open"></i><span> 分类</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fa fa-tags"></i><span> 标签</span></a></li><li><a class="site-page child" href="/archives/"><i class="fa-fw fa fa-folder-open"></i><span> 归档</span></a></li></ul></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> Demo</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/c2c_shop/"><i class="fa-fw fa fa-comments-o"></i><span> 商城</span></a></li></ul></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://chen-1317386995.cos.ap-guangzhou.myqcloud.com/Blog/images/PYTHON.png')"><nav id="nav"><span id="blog-info"><a href="/" title="C·辰"><span class="site-name">C·辰</span></a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search" href="javascript:void(0);"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fa fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fa fa-graduation-cap"></i><span> 博文</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/categories/"><i class="fa-fw fa fa-folder-open"></i><span> 分类</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fa fa-tags"></i><span> 标签</span></a></li><li><a class="site-page child" href="/archives/"><i class="fa-fw fa fa-folder-open"></i><span> 归档</span></a></li></ul></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> Demo</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/c2c_shop/"><i class="fa-fw fa fa-comments-o"></i><span> 商城</span></a></li></ul></div></div><div id="toggle-menu"><a class="site-page" href="javascript:void(0);"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">Python</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2021-05-02T14:22:22.000Z" title="发表于 2021-05-02 22:22:22">2021-05-02</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2023-07-27T10:16:06.808Z" title="更新于 2023-07-27 18:16:06">2023-07-27</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/Python/">Python</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">3.3k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>14分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="Python"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="Hello"><a href="#Hello" class="headerlink" title="Hello"></a>Hello</h1><figure class="highlight python"><table><tr><td class="code"><pre><span class="line">与c不同：</span><br><span class="line"></span><br><span class="line">列表<span class="built_in">list</span>     [ ]       c=[<span class="string">&#x27;hello&#x27;</span>,<span class="string">&#x27;1&#x27;</span>]  c=<span class="built_in">list</span>([])</span><br><span class="line">元组<span class="built_in">tuple</span>    ( )       c=(<span class="string">&#x27;hello&#x27;</span>,<span class="string">&#x27;python&#x27;</span>,<span class="number">99</span>)      --不可变</span><br><span class="line">字典dist     &#123; &#125;       c=&#123;<span class="string">&#x27;陈&#x27;</span>：<span class="number">99</span>&#125;      c=<span class="built_in">dict</span>(name=<span class="string">&#x27;age&#x27;</span>,辰=<span class="string">&#x27;1&#x27;</span>,num=<span class="string">&#x27;11&#x27;</span>,up=<span class="number">10</span>)    key：value</span><br><span class="line">集合<span class="built_in">set</span>      &#123; &#125;       c=&#123;<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>,<span class="number">4</span>,<span class="number">5</span>,<span class="number">6</span>&#125;     key</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="number">1.</span>不用定义变量</span><br><span class="line"></span><br><span class="line"><span class="number">2.</span>不用加括号</span><br><span class="line"></span><br><span class="line"><span class="number">3.</span>a++不适用---a+=<span class="number">1</span></span><br><span class="line"></span><br><span class="line"><span class="number">4.</span>函数条件后需要加   ：</span><br><span class="line"></span><br><span class="line"><span class="number">5.</span> ,不合适多变量定义，需要用;</span><br><span class="line"></span><br><span class="line"><span class="number">6.</span><span class="keyword">break</span> 等效  <span class="keyword">continue</span> 等效</span><br><span class="line"></span><br><span class="line"><span class="number">7.</span>\n 换行 也可输出空--<span class="built_in">print</span>()         \t 空格</span><br><span class="line"></span><br><span class="line"><span class="number">8.</span>嵌套循环的<span class="keyword">break</span>作用于嵌套的循环中，<span class="keyword">continue</span>结束当前循环，继续下一步</span><br><span class="line"></span><br><span class="line"><span class="number">9.</span>查看格式  <span class="built_in">print</span>(<span class="string">&#x27;地址&#x27;</span>,<span class="built_in">id</span>(name),<span class="string">&#x27;类型:&#x27;</span>,<span class="built_in">type</span>(name),<span class="string">&#x27;内容:&#x27;</span>,name)</span><br><span class="line"></span><br><span class="line"><span class="number">10.</span>输出默认为换行输出   不执行换行操作----<span class="built_in">print</span>(*，end=<span class="string">&#x27; &#x27;</span>)   <span class="comment">#输出每个元素后面跟着空格继续输出下一元素</span></span><br><span class="line"></span><br><span class="line"><span class="number">11.</span>退格：\b     换行：\n     纵向制表符：\v     横向制表符：\t       回车：\r         tab间距：\t</span><br><span class="line">   <span class="built_in">print</span>(c,<span class="string">&#x27;\t&#x27;</span>,end=<span class="string">&#x27; &#x27;</span>)</span><br><span class="line">   <span class="built_in">print</span>(<span class="string">&#x27;C&#x27;</span>*<span class="number">5</span>)        <span class="comment">#】CCCCCC</span></span><br><span class="line"></span><br><span class="line"><span class="number">12.</span>小写转大写 .upper(空)</span><br><span class="line"></span><br><span class="line"><span class="number">13.</span> 可变序列：    ①列表    ②字典</span><br><span class="line">    不可变序列：   ①字符串  ②元组</span><br><span class="line"></span><br><span class="line"><span class="number">14.</span>调用函数用()</span><br><span class="line">   空列表  lst=[]    lst=<span class="built_in">list</span>()</span><br><span class="line">   空字典    d=&#123;&#125;      d=<span class="built_in">dict</span>()</span><br><span class="line">   空元组    t=()      t=<span class="built_in">tuple</span>()</span><br><span class="line"></span><br><span class="line"><span class="number">15.</span>元组中嵌套列表可修改列表的值    c=(<span class="number">10</span>,[<span class="number">1</span>,<span class="number">2</span>,<span class="number">8</span>],<span class="number">3</span>)  c[<span class="number">1</span>][<span class="number">0</span>]=<span class="number">9</span>          输出：(<span class="number">10</span>, [<span class="number">1</span>, <span class="number">2</span>, <span class="number">9</span>], <span class="number">3</span>)</span><br><span class="line">                              进行添加         c[<span class="number">1</span>].append(<span class="number">0</span>)       输出：(<span class="number">10</span>, [<span class="number">1</span>, <span class="number">2</span>, <span class="number">9</span>, <span class="number">0</span>], <span class="number">3</span>)</span><br><span class="line">                              进行删除操作      c[<span class="number">1</span>].remove(<span class="number">2</span>)       输出：(<span class="number">10</span>, [<span class="number">1</span>, <span class="number">9</span>, <span class="number">0</span>], <span class="number">3</span>)</span><br><span class="line"></span><br><span class="line"><span class="number">16.</span>判断是否存在元素 --<span class="keyword">in</span>     <span class="keyword">not</span> <span class="keyword">in</span>                  <span class="comment">#  print(10 in r)  == #True</span></span><br><span class="line"></span><br><span class="line"><span class="number">17.</span>一行实现输入：  a,b,c=<span class="built_in">map</span>(<span class="built_in">int</span>,<span class="built_in">input</span>().split())   split()默认以空格间隔为输入 如输入格式为    <span class="number">3</span>  ,<span class="number">4</span>  则为x,y=<span class="built_in">input</span>().split(<span class="string">&#x27;，&#x27;</span>)</span><br><span class="line"></span><br><span class="line"><span class="number">18.</span>输出：</span><br><span class="line">            宽度：x%d</span><br><span class="line"></span><br><span class="line">            %占位符： <span class="built_in">print</span>(<span class="string">&#x27;f(%.1f) = %.1f&#x27;</span>%(x,x)) //  <span class="built_in">print</span>(<span class="string">&#x27;f(%d) = %d&#x27;</span>%(x,x))     //<span class="built_in">print</span>(f(%d)%x)</span><br><span class="line">                                  待输出数据不需要，</span><br><span class="line">           &#123;位置，索引&#125;：   <span class="built_in">print</span>(<span class="string">&#x27;f(&#123;0：.1f&#125;) = &#123;1:.1f&#125;&#x27;</span>.<span class="built_in">format</span>(x,x))</span><br><span class="line"></span><br><span class="line">            f-string :  <span class="built_in">print</span>(<span class="string">f&#x27;我叫<span class="subst">&#123;name&#125;</span>,今年<span class="subst">&#123;age&#125;</span>)</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">20.sum(求和函数)    例子   s=sum(a+i for i in range(1,n+1))</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">21.字符串   可数学运算 如 a=&#x27;</span><span class="number">1</span><span class="string">&#x27; s=a*2  s=11</span></span><br><span class="line"><span class="string">           str函数   b=a.strip()  默认去除空格</span></span><br><span class="line"><span class="string">                    如 c=&#x27;</span>111456python<span class="string">&#x27;  c.strip(&#x27;</span><span class="number">156</span><span class="string">&#x27;)    输出：456pytho</span></span><br><span class="line"><span class="string">           字符串可才用c[n]查看</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">21.比较函数  c=[2,3,1,5,6]  h=sorted(c)     h=[1, 2, 3, 5, 6]</span></span><br><span class="line"><span class="string">            print(*sorted(map(int,input().split())),sep=&quot;,&quot;)</span></span><br><span class="line"><span class="string">                 * 使用后面的sep，没有则输出数组形式       sep=&quot;&quot; 输出格式连接词</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">22.生成式   ①列表生成式    c=[i*i for i in range(6)]</span></span><br><span class="line"><span class="string">           ②计算--求和    s=sum(a*i for i in range(1,n+1))</span></span><br><span class="line"><span class="string">           ③集合生成式     c=&#123; i*i for i in range(6)&#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">数学运算符 + ，- ，*， / ，//（整除），%（取余），a**b（幂运算）</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">类型               int   float   bool    str=&#x27;</span>类型<span class="string">&#x27;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">类型转换            如 str c=&#x27;</span><span class="number">123</span><span class="string">&#x27;,转换 int(c)</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">不用特意定义变量类型   如 c=1000 (默认为 int 类型),  c=&#x27;</span>abc<span class="string">&#x27;(str类型)， c=1.1(float类型)</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">地址与类型          print( &#x27;</span>地址:<span class="string">&#x27;id(c)    &#x27;</span>类型<span class="string">&#x27;  type(C) )</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">输出--单双引号都可    print(&#x27;</span><span class="string">&#x27;)  &amp;&amp;   print(&quot;&quot;)   &amp;&amp;    print(c)</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">连接输出(变量+中文+变量)  int类型需要转str 如int类型的a，b   print( str(a)+&#x27;</span>大于等于<span class="string">&#x27;+str(b) if a&gt;=b else tr(a)+&#x27;</span>小于<span class="string">&#x27;+str(b) )</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">输入--变量           c = int (input(&#x27;</span>提示语<span class="string">&#x27;))      不定义变量默认为str结构</span></span><br><span class="line"><span class="string">                        类型         提示</span></span><br><span class="line"><span class="string">且和或              and  or</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">分支结构--判断--不用加括号-加冒号  if c&gt;=a:        if 条件表达体：</span></span><br><span class="line"><span class="string">                              else：               条件执行体</span></span><br><span class="line"><span class="string">                                                   if 条件执行体--嵌套：</span></span><br><span class="line"><span class="string">                                                       执行体</span></span><br><span class="line"><span class="string">                                                   elif（else) (条件执行体)</span></span><br><span class="line"><span class="string">                                                        执行体</span></span><br><span class="line"><span class="string">                                              elif 条件表达体：</span></span><br><span class="line"><span class="string">                                                  条件执行体2</span></span><br><span class="line"><span class="string">                                              else：</span></span><br><span class="line"><span class="string">                                                 条件执行体</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">                              区间写法 90&lt;=num&lt;=100     且 and 或or</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">                  if elif--简写    print((True 内容)  判断语句  (false 内容))</span></span><br><span class="line"><span class="string">                                         (a&gt;=b)      if a&gt;=b   (a&lt;b)</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">                pass-- 空条件执行体       if not 否</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">----内置函数(不可更改)   range()    -----生成一个整数序列</span></span><br><span class="line"><span class="string">range(stop)                  ------r=range(10)      #[0,1,2,3,4,5,6,7,8,9] 默认从0开始r    元素间距为1</span></span><br><span class="line"><span class="string">range(start,stop)            ------r=range(1,10)     #[1, 2, 3, 4, 5, 6, 7, 8, 9]         元素间距为1</span></span><br><span class="line"><span class="string">range(start,stop,step)       ------r=range(1,10,2)   #[1, 3, 5, 7, 9]</span></span><br><span class="line"><span class="string">       起点  终点  间距</span></span><br><span class="line"><span class="string">输出数组 print(list(r))          #以数列输出</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">使用range生成列表(开n个列表(数组))：c=[i for i in range(start,stop)]</span></span><br><span class="line"><span class="string">                                c=[i(可运算 如i*i i+i) for i in range(1,10)]  print(c)  [1, 2, 3, 4, 5, 6, 7, 8, 9]</span></span><br><span class="line"><span class="string">                                   表达式                 自定义变量  可迭代变量</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">(数组)列表(可变序列）--    直接使用 c=[&#x27;</span>hello<span class="string">&#x27;,&#x27;</span><span class="number">1</span><span class="string">&#x27;]    调用list函数 c=list([&#x27;</span>hello<span class="string">&#x27;])     从后面遍历回来，从-1开始  -N到-1</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">        查询：     查看当前位置 c.index(&#x27;</span>hello<span class="string">&#x27;)==0    c.index(1)==1</span></span><br><span class="line"><span class="string">                  指定位置查找 c.index(&#x27;</span>hello<span class="string">&#x27;,0,2)  ----开区间查找</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">        区域输出 -- 切片段-形成新的列表       区域输出    print(c[start:Stop:step])   #起点 终点 布距(可默认）</span></span><br><span class="line"><span class="string">                                         默认情况    print(c[::])   输出全列表</span></span><br><span class="line"><span class="string">                                         倒序输出    print(c[::-1])</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">        遍历：                  判断  in     &amp;&amp;     not in</span></span><br><span class="line"><span class="string">                               for i in c:   ##赋值给i</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">        添加：                  末尾添加：append()</span></span><br><span class="line"><span class="string">                                       c.append(2)  # [&#x27;</span>hello<span class="string">&#x27;, &#x27;</span><span class="number">1</span><span class="string">&#x27;, 100]</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">                             末尾至少添加一个元素(把另一个列表添加到一个列表中&quot;:扩展&quot;）：extend()</span></span><br><span class="line"><span class="string">                                                                               c.append(2)  # [&#x27;</span>hello<span class="string">&#x27;, &#x27;</span><span class="number">1</span><span class="string">&#x27;, 100]</span></span><br><span class="line"><span class="string">                                                                               c1 = [, 6, 7, 8]</span></span><br><span class="line"><span class="string">                                                                               c.extend(c1)  # [&#x27;</span>hello<span class="string">&#x27;, 1, 6, 7, 8]</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">                            任意位置添加：insert</span></span><br><span class="line"><span class="string">                                  插入：c.insert(1,99)            #[&#x27;</span>hello<span class="string">&#x27;, 99, &#x27;</span><span class="number">1</span><span class="string">&#x27;]</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">                            切片(切去，舍，后插入多元素)：从c[1:]=c1      #[&#x27;</span>hello<span class="string">&#x27;, 6, 7, 8]</span></span><br><span class="line"><span class="string">                                            1位置包括1，后面舍去，前面保留</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">        删除：                remove()   一次删除一个元素   重复的只能删除第一个</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">        创建空列表： c=[]    c=list()</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">循环结构  while   和     for-in</span></span><br><span class="line"><span class="string">  /  while 条件判断体：                   #不加括号</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">  /  for(a)in(b)     将b的值逐一赋值给a  --</span></span><br><span class="line"><span class="string">     for a in &#x27;</span>abc<span class="string">&#x27;:</span></span><br><span class="line"><span class="string">     print(a)     a b c</span></span><br><span class="line"><span class="string">   作为循环体 for i in range(5)    ---循环体 从0到5</span></span><br><span class="line"><span class="string">                _   为循环执行输出用</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">                                                       key键   值（’可中文’）</span></span><br><span class="line"><span class="string">字典(可变序列)  --每个元素两个成员  使用内置函数 dict   c=dict(name=&#x27;</span>age<span class="string">&#x27;,辰=&#x27;</span><span class="number">1</span><span class="string">&#x27;,num=&#x27;</span><span class="number">11</span><span class="string">&#x27;,up=10)      &#123;&#x27;</span>name<span class="string">&#x27;: &#x27;</span>age<span class="string">&#x27;, &#x27;</span>now<span class="string">&#x27;: 1, &#x27;</span>num<span class="string">&#x27;: 11, &#x27;</span>up<span class="string">&#x27;: 10&#125;</span></span><br><span class="line"><span class="string">                (key不可重复)                     c=&#123;&#x27;</span>陈<span class="string">&#x27;：99&#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">    /所有元素都是一个key-value对，key不可重复，valu可重复 ；元素都是无序的 ；key不可更改</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">    /创建    c=&#123;&#x27;</span>陈<span class="string">&#x27;：1,&#x27;</span>c<span class="string">&#x27;:2,3&#125;          c=dict&#123;name:&#x27;</span>numbe<span class="string">r&#x27;,c:2&#125;   两种赋值方法代入</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">    /空字典  c=&#123;&#125;                                 键    值</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">    /查看    调用键查看值</span></span><br><span class="line"><span class="string">            ①   []     print(c[&#x27;</span>辰<span class="string">&#x27;])  ==  1        键不存在 报错：不存在      格式 字典名[key]</span></span><br><span class="line"><span class="string">            ②   get()  c.get(&#x27;</span>辰<span class="string">&#x27;)     ==  1        键不存在 None            格式 字典名.get(key)</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">    /判断存在   print(’辰‘ in c)      True</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">    /删除      del c[&#x27;</span>num<span class="string">&#x27;]     删除整对       格式  del 字典名[key]</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">    /清空      c.clear()</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">    /添加      c[&#x27;</span>玖<span class="string">&#x27;]=98         格式  [key]=Value</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">    /修改      c[&#x27;</span>辰<span class="string">&#x27;]=99         格式  [key]=value</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">    /获取数据    ① 所有key ：y = c.keys()     dict_keys类型   转list类型  print(list(y))</span></span><br><span class="line"><span class="string">                ②所有值   ：y = c.values()   dict_values类型  转list类型  print(list(y))</span></span><br><span class="line"><span class="string">                ③所有键值对：y = c.items()    dict_items类型  [(&#x27;</span>name<span class="string">&#x27;, &#x27;</span>age<span class="string">&#x27;), (&#x27;</span>辰<span class="string">&#x27;, 1), (&#x27;</span>num<span class="string">&#x27;, &#x27;</span><span class="number">11</span><span class="string">&#x27;), (&#x27;</span>up<span class="string">&#x27;, 10)]</span></span><br><span class="line"><span class="string">                                                                  （） 元组</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">    /遍历     for i in c:</span></span><br><span class="line"><span class="string">                print(i)    (键)</span></span><br><span class="line"><span class="string">                print(c[i],c.get(i))  (值)</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">    /生成式    zip() 打包</span></span><br><span class="line"><span class="string">             key=[&#x27;</span>one<span class="string">&#x27;,&#x27;</span>two<span class="string">&#x27;,&#x27;</span>three<span class="string">&#x27;,&#x27;</span>fou<span class="string">r&#x27;]</span></span><br><span class="line"><span class="string">             valu=[1,2,3,4]</span></span><br><span class="line"><span class="string">             c=&#123;key:valu for key,valu in zip(key,valu)&#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">元组 --不可更改   ()</span></span><br><span class="line"><span class="string">    /创建     ① 使用 ()                     c=(&#x27;</span>hello<span class="string">&#x27;,&#x27;</span>python<span class="string">&#x27;,99) 输出：(&#x27;</span>hello<span class="string">&#x27;, &#x27;</span>python<span class="string">&#x27;, 99)</span></span><br><span class="line"><span class="string">                        只有一个元素，需加，   c=(&#x27;</span>python<span class="string">&#x27;,)      c=&#x27;</span>python<span class="string">&#x27;,</span></span><br><span class="line"><span class="string">                        可省略括号           c=&#x27;</span>hello<span class="string">&#x27;,&#x27;</span>python<span class="string">&#x27;,99</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">             ② 使用内置函数 tuple            c=tuple((&#x27;</span>hello<span class="string">&#x27;,&#x27;</span>python<span class="string">&#x27;,99))    *双括号      输出：(&#x27;</span>hello<span class="string">&#x27;, &#x27;</span>python<span class="string">&#x27;, 99)</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">             ③ 空元组                       c=()  //  c=tuple()</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">     /定位查看        索引                    c[i]</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">    /遍历  for i in c</span></span><br><span class="line"><span class="string">            print(i)</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">集合--可改变序列   &#123; &#125;   只有key 没有值    key不可重复    无序</span></span><br><span class="line"><span class="string">    /创建     ①使用&#123; &#125;                      c=&#123;1,1,2,2,3,3,4,5,6&#125;     输出：&#123;1, 2, 3, 4, 5, 6&#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">    /其他类型转换成集合————使用 set 函数-----无序</span></span><br><span class="line"><span class="string">                    ①range转成集合       c=set(range(6))                输出：&#123;0, 1, 2, 3, 4, 5&#125;</span></span><br><span class="line"><span class="string">                    ②列表转成集合         c=set([7,8,9,&#x27;</span>python<span class="string">&#x27;])        输出：&#123;8, 9, &#x27;</span>python<span class="string">&#x27;, 7&#125;</span></span><br><span class="line"><span class="string">                    ③元组转成集合         c=set((3,4,5,&#x27;</span>python<span class="string">&#x27;))        输出：&#123;3, 4, 5, &#x27;</span>python<span class="string">&#x27;&#125;</span></span><br><span class="line"><span class="string">                    ④字符串转集合         c=set(&#x27;</span>python<span class="string">&#x27;)                输出：&#123;&#x27;</span>h<span class="string">&#x27;, &#x27;</span>o<span class="string">&#x27;, &#x27;</span>t<span class="string">&#x27;, &#x27;</span>n<span class="string">&#x27;, &#x27;</span>p<span class="string">&#x27;, &#x27;</span>y<span class="string">&#x27;&#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">    /空集合      c=set()</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">                c=&#123;1,2,3,4,5,6,7&#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">    /添加       add()     -------一次添加一个：</span></span><br><span class="line"><span class="string">                        c.add(8)      输出：&#123;1, 2, 3, 4, 5, 6, 7, 8&#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">               update()  ---------至少添加一个元素：</span></span><br><span class="line"><span class="string">                        ①添加新集合到原集合：c.update(&#123;9,10,11&#125;)                   输出：&#123;1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11&#125;</span></span><br><span class="line"><span class="string">                        ②添加列表到集合中  ：c.update([&#x27;</span>one<span class="string">&#x27;,&#x27;</span>two<span class="string">&#x27;,&#x27;</span>three<span class="string">&#x27;])      输出：&#123;1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, &#x27;</span>one<span class="string">&#x27;, &#x27;</span>three<span class="string">&#x27;, &#x27;</span>two<span class="string">&#x27;&#125;</span></span><br><span class="line"><span class="string">                        ③添加元组到集合中  ：c.update((&#x27;</span>fou<span class="string">r&#x27;,&#x27;</span>five<span class="string">&#x27;,16))         输出：&#123;1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, &#x27;</span>one<span class="string">&#x27;, &#x27;</span>three<span class="string">&#x27;, &#x27;</span>five<span class="string">&#x27;, 16, &#x27;</span>two<span class="string">&#x27;, &#x27;</span>fou<span class="string">r&#x27;&#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">    /删除      remove()  ----------一次删除一个指定元素 ，如果指定元素不存在抛出异常  KeyError</span></span><br><span class="line"><span class="string">                        c.remove(7)</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">              discard() ---------- 一次删除一个指定元素，如果指定元素不存在不抛出异常</span></span><br><span class="line"><span class="string">                        c.discard(7)</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">              pop()     ----------一次只删除一个任意元素</span></span><br><span class="line"><span class="string">                        c.pop()</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">              clear()   ----------- 清空集合</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">    /两集合的关系：   c=&#123;1,2,3,4,5,6,7&#125;   c1=&#123;1,2,3&#125;  c2=&#123;6,5,4,3&#125;</span></span><br><span class="line"><span class="string">                   ① 等与不等  ==  ！=</span></span><br><span class="line"><span class="string">                   ②判断子集(小是大的子集)          c1.issubset(c)                         -----True</span></span><br><span class="line"><span class="string">                   ③判断超集(大的是小的超集)        c.issuperset(c1)                        -----True</span></span><br><span class="line"><span class="string">                   ④判断交集                      c1.isdisjoint(s3)                      ----False (相反结果)</span></span><br><span class="line"><span class="string">                   ⑤交集                          c1.intersection(c2)                   -----&#123;3&#125;</span></span><br><span class="line"><span class="string">                                                  c1 &amp; c2                               -----&#123;3&#125;</span></span><br><span class="line"><span class="string">                   ⑥并集                          c1.union(c2)                          -----&#123;1, 2, 3, 4, 5, 6&#125;</span></span><br><span class="line"><span class="string">                                                  c1+c2</span></span><br><span class="line"><span class="string">                   ⑦差集                          c2.difference(c1)                     -----&#123;4, 5, 6&#125;  (c2 - c1)</span></span><br><span class="line"><span class="string">                                                  c2-c1</span></span><br><span class="line"><span class="string">                   ⑧对称差集                       c1.symmetric_difference(c2))          -----&#123;1, 2, 4, 5, 6&#125;  (-同)</span></span><br><span class="line"><span class="string">                                                  c1^c2</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">字符串：            c=&#x27;</span>pythonn<span class="string">&#x27;  c1=&quot;pythonn&quot;  c=2&#x27;</span><span class="string">&#x27;&#x27;</span>pythonn<span class="string">&#x27;&#x27;&#x27;         驻留机制---相等--当下一变量相等时间时直接从 字符串池 赋值</span></span><br><span class="line"><span class="string">                   c1=&#x27;p&#x27; ;  c2=&#x27;n&#x27;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">                ①查找：c.find(c1)            --查找第一次出现的位置，不存在返回-1                 输出：0</span></span><br><span class="line"><span class="string">                       c.index(c1)          --查找第一次出现的位置，不存在抛出ValueError</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">                       c.rfind(c1)          --查找最后一次出现的位置，不存在返回-1</span></span><br><span class="line"><span class="string">                       c.rindex(c1)         --查找最后一次出现的位置，不存在抛出ValueError</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">                ②相加：c=&#x27; &#x27;.join([&#x27;ab&#x27;,&#x27;c&#x27;])</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">                ③转换大写(元字符串无变化)：         s=c.uppeer()                输出：PYTHONN</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">                 转换小写：                      s=c.lower()</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">                大写转小写，小学转大写：           s=c.swapcase()</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">                第一个字符转换为大写，其余转小写：   s=c.capitalize()</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">                把每个单词的第一个字符转换为大写，每个单词的其余字符串转为小写：s=c.title()</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">                ④对齐操作：  /中间对齐： c.center(总空间x，填充物质(默认空格)&#x27;*&#x27;)      c.center(20,&#x27;*&#x27;)      输出：******pythonn*******</span></span><br><span class="line"><span class="string">                            /左对齐  ：c.ljust(总空间x，填充物质&#x27;*&#x27;)</span></span><br><span class="line"><span class="string">                            /右对齐  ：c.rjust(总空间x，填充物质&#x27;*&#x27;)</span></span><br><span class="line"><span class="string">                            /右对齐(0填充)：c.zfill(x)</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">                ⑤劈分(分割，形成列表):    c=&#x27;hello world for python&#x27;</span></span><br><span class="line"><span class="string">                                       l=c.split(sep=&#x27;指定符号劈分&#x27;)    (默认空格)                      输出：[&#x27;hello&#x27;, &#x27;world&#x27;, &#x27;for&#x27;, &#x27;python&#x27;]</span></span><br><span class="line"><span class="string">                                左劈分  l=c.split(sep=&#x27;|&#x27;,maxsplit=(劈分单词数量x))        l=c.split(sep=&#x27;|&#x27;,maxsplit=(1))     输出：</span></span><br><span class="line"><span class="string">                                右劈分：l=c.rsplit()</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">                ⑥判断是否合法： 合法--字母加下划线_   :c.isidentifier()</span></span><br><span class="line"><span class="string">                              空白字符串组成(回车，换行符，水平制表符)：  c.isspace()</span></span><br><span class="line"><span class="string">                              全部字母组成：   c.isalpha()</span></span><br><span class="line"><span class="string">                              全部由十进制的数字组成：c.isdecimal()</span></span><br><span class="line"><span class="string">                              全部数字组成：c.isnumeric()</span></span><br><span class="line"><span class="string">                              全部由数字和字母组成： c.isalnum</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">                ⑦字符串替换： c.replace(&#x27;被替换字符&#x27;,&#x27;替换的字符&#x27;,&#x27;最大替换次数&#x27;)</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">                ⑧合并(将列表合并成一个字符串)：c=[&#x27;hello&#x27;, &#x27;world&#x27;, &#x27;for&#x27;, &#x27;python&#x27;]</span></span><br><span class="line"><span class="string">                                            print(&#x27;间隔符&#x27;.join(c))         输出：hello world for python</span></span><br><span class="line"><span class="string">                                                            #(为字符则间隔为&#x27;间隔符&#x27;)</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">                ⑨比较   &gt; &gt;= &lt; &lt;= ==</span></span><br><span class="line"><span class="string">                        c1=&#x27;hello&#x27; c2=&#x27;python&#x27;  c1&gt;c2</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">                ⑩切片：(产生新对象)  s[起始位置：终点]  s[start:stop:step]</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">                编码转换：</span></span><br><span class="line"><span class="string">                        将字符串转为二进制（bytes）:s=&#x27;天涯何处无芳草&#x27;</span></span><br><span class="line"><span class="string">                                                        编码：     s.encode(encoding=&#x27;GBK&#x27;)  #在GBK格式中，一个中文占两个字节</span></span><br><span class="line"><span class="string">                                                        解码：     # byte代表二进制数据</span></span><br><span class="line"><span class="string">                                                                  byte=s.decode(encoding=&#x27;GBK&#x27;)</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">                                                        编码：     s.encode(encoding=&#x27;UTF-8&#x27;) #在UTF-8格式中，一个中文占三个字节</span></span><br><span class="line"><span class="string">                                                        解码：     #byte代表二进制数据</span></span><br><span class="line"><span class="string">                                                                  byte=s.decode(encoding=&#x27;UTF-8&#x27;)</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">函数的创建和调用：</span></span><br><span class="line"><span class="string">                创建：def 函数名 ([输入参数]) ：                          def calc(a,b):</span></span><br><span class="line"><span class="string">                        函数体                                             c=a+b</span></span><br><span class="line"><span class="string">                        [return x]                                        return c</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">                调用：r=calc(10,20)</span></span><br></pre></td></tr></table></figure>



</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="http://example.com">辰</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="http://example.com/2021/05/02/Python/">http://example.com/2021/05/02/Python/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="http://example.com" target="_blank">C·辰</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/Python/">Python</a></div><div class="post_share"><div class="social-share" data-image="https://chen-1317386995.cos.ap-guangzhou.myqcloud.com/Blog/images/PYTHON.png" data-sites="wechat,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/2021/01/01/Java%E5%9F%BA%E7%A1%80/" title="Java"><img class="cover" src= "" data-lazy-src="/img/loading.gif" data-original="https://chen-1317386995.cos.ap-guangzhou.myqcloud.com/Blog/images/Java.png" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">Java</div></div></a></div><div class="next-post pull-right"><a href="/2023/04/01/Blog/" title="Blog"><img class="cover" src= "" data-lazy-src="/img/loading.gif" data-original="https://chen-1317386995.cos.ap-guangzhou.myqcloud.com/Blog/images/page1.jpg" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">Blog</div></div></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src= "" data-lazy-src="/img/loading.gif" data-original="https://chen-1317386995.cos.ap-guangzhou.myqcloud.com/Blog%2Fimages%2Favatar.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">辰</div><div class="author-info__description">车遥马慢</div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">32</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">28</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">10</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://gitee.com/hchenp"><i class="fab fa-github"></i><span>Gitee-HchenP</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://gitee.com/hchenp" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="https://github.com/Pxlchen?tab=projects" target="_blank" title="CSDN"><i class="fa fa-book-open"></i></a><a class="social-icon" href="https://console.cloud.tencent.com/cos/bucket?bucket=chen-1317386995&amp;region=ap-guangzhou&amp;isPublic=true" target="_blank" title="QQ"><i class="fab fa-qq"></i></a><a class="social-icon" href="mailto:1107383160@qq.com" target="_blank" title="Email"><i class="fas fa-envelope-open-text"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">C2C-Blog</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content is-expand"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#Hello"><span class="toc-number">1.</span> <span class="toc-text">Hello</span></a></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/2023/07/06/Java%E5%85%AB%E8%82%A1%E6%96%87/" title="Java八股文"><img src= "" data-lazy-src="/img/loading.gif" data-original="https://chen-1317386995.cos.ap-guangzhou.myqcloud.com/Blog/images/javaall.gif" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Java八股文"/></a><div class="content"><a class="title" href="/2023/07/06/Java%E5%85%AB%E8%82%A1%E6%96%87/" title="Java八股文">Java八股文</a><time datetime="2023-07-06T14:22:22.000Z" title="发表于 2023-07-06 22:22:22">2023-07-06</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2023/07/06/%E5%90%8E%E7%AB%AF%E8%A7%84%E5%88%92/" title="Java后端"><img src= "" data-lazy-src="/img/loading.gif" data-original="https://chen-1317386995.cos.ap-guangzhou.myqcloud.com/Blog/images/javahd.jpeg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Java后端"/></a><div class="content"><a class="title" href="/2023/07/06/%E5%90%8E%E7%AB%AF%E8%A7%84%E5%88%92/" title="Java后端">Java后端</a><time datetime="2023-07-06T14:22:22.000Z" title="发表于 2023-07-06 22:22:22">2023-07-06</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2023/06/02/MybatisPlus/" title="MybatisPlus"><img src= "" data-lazy-src="/img/loading.gif" data-original="https://chen-1317386995.cos.ap-guangzhou.myqcloud.com/Blog/images/mybatisplus.svg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="MybatisPlus"/></a><div class="content"><a class="title" href="/2023/06/02/MybatisPlus/" title="MybatisPlus">MybatisPlus</a><time datetime="2023-06-02T14:22:22.000Z" title="发表于 2023-06-02 22:22:22">2023-06-02</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2023/05/05/Linux/" title="Linux"><img src= "" data-lazy-src="/img/loading.gif" data-original="https://chen-1317386995.cos.ap-guangzhou.myqcloud.com/Blog/images/Linux.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Linux"/></a><div class="content"><a class="title" href="/2023/05/05/Linux/" title="Linux">Linux</a><time datetime="2023-05-05T14:22:22.000Z" title="发表于 2023-05-05 22:22:22">2023-05-05</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2023/05/05/Redis/" title="Redis"><img src= "" data-lazy-src="/img/loading.gif" data-original="ttps://chen-1317386995.cos.ap-guangzhou.myqcloud.com/Blog/images/Redis.jpeg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Redis"/></a><div class="content"><a class="title" href="/2023/05/05/Redis/" title="Redis">Redis</a><time datetime="2023-05-05T14:22:22.000Z" title="发表于 2023-05-05 22:22:22">2023-05-05</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2023 By 辰</div><div class="framework-info"><a target="_blank" rel="noopener" href="https://beian.miit.gov.cn">粤ICP备2023096650号</a><span class="footer-separator">|</span><a target="_blank" rel="noopener" href="http://hchen.cloud">hchen.cloud</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.umd.min.js"></script><script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js"></script><div class="js-pjax"></div><canvas class="fireworks" mobile="false"></canvas><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/fireworks.min.js"></script><script defer="defer" id="fluttering_ribbon" mobile="false" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/canvas-fluttering-ribbon.min.js"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div class="no-result" id="local-search-results"></div><div id="local-search-stats-wrap"></div></div></div><div id="search-mask"></div><script src="/js/search/local-search.js"></script></div></div>
        <style>
            [bg-lazy] {
                background-image: none !important;
                background-color: #eee !important;
            }
        </style>
        <script>
            window.imageLazyLoadSetting = {
                isSPA: false,
                preloadRatio: 1,
                processImages: null,
            };
        </script><script>window.addEventListener("load",function(){var t=/\.(gif|jpg|jpeg|tiff|png)$/i,r=/^data:image\/[a-z]+;base64,/;Array.prototype.slice.call(document.querySelectorAll("img[data-original]")).forEach(function(a){var e=a.parentNode;"A"===e.tagName&&(e.href.match(t)||e.href.match(r))&&(e.href=a.dataset.original)})});</script><script>!function(r){r.imageLazyLoadSetting.processImages=t;var e=r.imageLazyLoadSetting.isSPA,n=r.imageLazyLoadSetting.preloadRatio||1,c=a();function a(){var t=Array.prototype.slice.call(document.querySelectorAll("img[data-original]")),e=Array.prototype.slice.call(document.querySelectorAll("[bg-lazy]"));return t.concat(e)}function t(){e&&(c=a());for(var t,o=0;o<c.length;o++)0<=(t=(t=c[o]).getBoundingClientRect()).bottom&&0<=t.left&&t.top<=(r.innerHeight*n||document.documentElement.clientHeight*n)&&function(){var t,e,n,a,i=c[o];e=function(){c=c.filter(function(t){return i!==t}),r.imageLazyLoadSetting.onImageLoaded&&r.imageLazyLoadSetting.onImageLoaded(i)},(t=i).hasAttribute("bg-lazy")?(t.removeAttribute("bg-lazy"),e&&e()):(n=new Image,a=t.getAttribute("data-original"),n.onload=function(){t.src=a,t.removeAttribute("data-original"),e&&e()},t.src!==a&&(n.src=a))}()}function i(){clearTimeout(t.tId),t.tId=setTimeout(t,500)}t(),document.addEventListener("scroll",i),r.addEventListener("resize",i),r.addEventListener("orientationchange",i)}(this);</script></body></html>